package steps
{
	import jnBase.BaseZhishi;
	import jnBase.Data;
	import jnBase.InsPages;
	import jnBase.PSteps;
	
	import laya.display.Sprite;
	import laya.events.Event;
	import laya.utils.Handler;
	import laya.utils.Tween;
	
	import ui.steps.step3_tiwenquxianUI;

	public class Step03_TiWenquXian extends step3_tiwenquxianUI implements InsPages
	{
		public var _scriptPage:PSteps;
		public var _scriptZhishi:BaseZhishi;
		private var zhishiStr:String="";
		public function Step03_TiWenquXian()
		{
			super();
			size(1920,1080);
			this.name="3.体温曲线的绘制";
			_scriptPage=this.addComponent(PSteps);
			_scriptZhishi=this.addComponent(BaseZhishi);
		}
		public function changeSonStep():void
		{
			switch(Data.currSonStep)
			{
				case 0:
				{
					step1();
					break;
				}
				case 1:
				{
					step2();
					break;
				}	
				default:
				{
					break;
				}
			}

		}
		private function step1():void
		{	
			dian1.alpha=dian2.alpha=dian3.alpha=dian4.alpha=dian5.alpha=dian6.alpha=dianH.alpha=xuxian.alpha=lowWen.alpha=reLiang.alpha=0;
			d1.alpha=d2.alpha=d3.alpha=d4.alpha=d5.alpha=remark1.alpha=remark2.alpha=jiangwenText.alpha=0;
			sp.graphics.clear();
			_scriptZhishi.showTips("体温曲线的绘制:每一小格为0.2℃，将实际测量的度数，用蓝笔绘制于体温单35～42℃的相应时间格内");
			Laya.timer.once(4000,this,function():void{
				Tween.to(dian1,{alpha:1},400);
				Tween.to(dian2,{alpha:1},800);
				Tween.to(dian3,{alpha:1},1200);
				Tween.to(dian4,{alpha:1},1600,null,Handler.create(this,function():void{
					_scriptZhishi.showTips("将相邻温度用蓝线相连，相同两次体温间可不连线");
					huaxian();
				}));
			});
		}	
		private var sp:Sprite = new Laya.Sprite();
		private function huaxian():void
		{
			Laya.stage.addChild(sp);
			//绘制折线
			sp.graphics.drawLine(721,693,809,593,"#052dff",3);
			Laya.timer.once(400,this,function():void{
				sp.graphics.drawLine(809,593,872,502,"#052dff",3);
				Laya.timer.once(400,this,function():void{
					sp.graphics.drawLine(872,502,915,626,"#052dff",3);
						Laya.timer.once(2000,this,function():void{
							_scriptPage.showSonStepByIndex(1);
						});
					});
				});
		}
		private function step2():void
		{
			// TODO Auto Generated method stub
			dian1.alpha=dian2.alpha=dian3.alpha=dian4.alpha=1;
			dian5.alpha=dian6.alpha=dianH.alpha=xuxian.alpha=0;
			d1.alpha=d2.alpha=d3.alpha=d4.alpha=d5.alpha=remark1.alpha=remark2.alpha=0;
			Laya.stage.addChild(sp);
			sp.graphics.drawLine(721,693,809,593,"#052dff",3);
			sp.graphics.drawLine(809,593,872,502,"#052dff",3);
			sp.graphics.drawLine(872,502,915,626,"#052dff",3);
			_scriptZhishi.showTips("物理或药物降温30分钟后，重测体温，测量的体温以红圈“О”表示，划在物理降温前温度的一纵格内");
			Tween.to(jiangwenText,{alpha:1},800);
			_scriptZhishi.xiankuangClick(851,574,41,41,function():void{
				_scriptZhishi.clearLoop();
				_scriptZhishi.hideAllZhishi();
				Tween.to(dianH,{alpha:1},400,null,Handler.create(this,function():void{
					_scriptZhishi.showTips("用红虚线与降温前的温度相连");
					_scriptZhishi.xiankuangClick(851,489,41,126,function():void{
						_scriptZhishi.clearLoop();
						_scriptZhishi.hideAllZhishi();
						Tween.to(xuxian,{alpha:1},800,null,Handler.create(this,function():void{
							_scriptZhishi.showTips("下次测得的温度用蓝线仍与降温前温度相连");
							Laya.timer.once(2000,this,function():void{
								Tween.to(dian5,{alpha:1},2000);
								Tween.to(dian6,{alpha:1},2400,null,Handler.create(this,function():void{
									sp.graphics.drawLine(915,626,928,655,"#052dff",3);
									Laya.timer.once(400,this,function():void{
										sp.graphics.drawLine(928,655,972,642,"#052dff",3);
										LowTemperature();
									});
								}));
							});
						}));
					});
					
				}));
			});
		}
		private function LowTemperature():void
		{
			Laya.timer.once(2000,this,function():void{
				_scriptZhishi.showTips("体温低于35℃时，为体温不升，应在35℃线以下相应时间纵格内用红钢笔写“不升”不再与相邻温度相连");
				_scriptZhishi.xiankuangClick(664,823,41,65,function():void{
					_scriptZhishi.clearLoop();
					_scriptZhishi.hideAllZhishi();
					Tween.to(lowWen,{alpha:1},800,null,Handler.create(this,function():void{
						_scriptZhishi.showTips("若病人体温与上次温度差异较大或与病情不符时，应重新测量，重测相符者在原体温符号上方用蓝笔写上一小写英文字母v");
						_scriptZhishi.xiankuangClick(897,586,35,35,function():void{
							_scriptZhishi.clearLoop();
							_scriptZhishi.hideAllZhishi();
							Tween.to(reLiang,{alpha:1},800,null,Handler.create(this,function():void{
								_scriptZhishi.showTips("若病人因拒测、外出进行诊疗活动或请假等原因未能测量体温时，则在体温单40～42℃横线之间用红钢笔在相应时间纵格内填写“拒测”“外出”或“请假”等");
								_scriptZhishi.xiankuangClick(981,165,35,57,function():void{
									_scriptZhishi.clearLoop();
									_scriptZhishi.hideAllZhishi();
									Tween.to(remark1,{alpha:1},400);
									Tween.to(remark2,{alpha:1},400,null,Handler.create(this,function():void{
										_scriptZhishi.showTips("前后两次体温断开不相连");
										d1.alpha=d2.alpha=d3.alpha=d4.alpha=d5.alpha=1;
										sp.graphics.drawLine(1046,590,1086,556,"#052dff",3);
										sp.graphics.drawLine(1086,556,1164,535,"#052dff",3);
										sp.graphics.drawLine(1164,535,1209,608,"#052dff",3);
										sp.graphics.drawLine(1209,608,1254,642,"#052dff",3);
										Laya.timer.once(2000,this,function():void{
											_scriptZhishi.showTips("一般情况下需每两小时测一次体温，记录在q2h体温专用单上。");
											Laya.timer.once(4000,this,function():void{
												_scriptPage.addPage(3);
											});
										});
									}));
								});
							}));
						});
					}));
				});
			});
		}
		
		/**
		 *切换二级菜单时自动调用
		 * 显示新的二级页面时会自动调用此方法 
		 * 
		 */		
		public function reset():void
		{
			_scriptZhishi.hideAll();
			removeAllListener();
			zhishiStr="";
			sp.graphics.clear();
		}
		/**
		 *移除所有监听 
		 * 
		 */		
		public function removeAllListener():void
		{
			_scriptZhishi.removeAllHandler();	
			sp.graphics.clear();
		}
		override public function onEnable():void{
			reset();
		}
		/**
		 *关闭时自动调用 
		 * @param type
		 * 
		 */		
		override public function close(type:String=null):void
		{
			// TODO Auto Generated method stub
			_scriptPage.enabled=false;
			_scriptZhishi.enabled=false;
			removeAllListener();
			Tween.to(this,{x:-GameConfig.width,alpha:0},300,null,Handler.create(this,closeSuper,[type]));
		}
		private function closeSuper(type:String=null):void{
			super.close(type);
		}
		/**
		 *每秒执行一次 
		 * 
		 */		
		public function lineLoop():void
		{
			// TODO Auto Generated method stub
			if(zhishiStr==""){
				_scriptZhishi.zhishiRect.alpha=1;
				Tween.to(_scriptZhishi.zhishiRect,{alpha:0.1},600);
			}
			else if(zhishiStr=="xi"){
				_scriptZhishi.mdown.visible=true;
				_scriptZhishi.mdown.pos(958,688);
				_scriptZhishi.mdown.rotation=-155;
				Tween.to(_scriptZhishi.mdown,{x:990,y:596},600);
			}
		}
		/**
		 *被移除时自动调用  
		 * 因为设置了自动销毁，所以关闭后后会执行销毁 ，因为关闭时加了一个动画，所以要300毫秒后才执行销毁
		 * 
		 */		
		override public function onDestroy():void{
			trace(this.name+"销毁");
		}
	}
}